package main

import (
    "fmt"
    "sync"
    "time"
)

var mutex sync.Mutex

func Wprintf(format string, a ...interface{}) string {
	str := fmt.Sprintf(format, a...)
	fmt.Println(str)
	return str
}

func Wnumb(i int) {
	mutex.Lock()
	for n:=0 ; n <5 ; n++ {
		 time.Sleep(time.Millisecond * 5)
		 Wprintf("%d\r\n", i)
	}
	mutex.Unlock()
}

func main() {
	fmt.Println("test sync log")
	for i := 0; i < 4; i++ {
        go Wnumb(i) 
    }
    time.Sleep(time.Second * 3)
}